<template>
	<view class="bods">
		<!-- //遮罩层 -->
		<view @click="show='true'" v-if="!show" class="propos">
		</view>
		<!-- //筛选列表 -->
		<!-- <view v-if="!show" class="propo">
			<view class="bt_props">
				<p style='font-size: 32rpx;'>类型</p>

				<view class="bt_pr">
					<view class='preparation' v-for="(r,index) in preparation" :key="index" @click="screen(r.txt)">
						<span>{{r.txt}}</span>
					</view>
				</view>
			</view>
		</view> -->
		<view style="background-color: white;">
			<!-- 查找筛选 -->
			<view class="seler">
				<u-search
					:clearabled='true' 
					placeholder="请输入主题内容" 
					v-model="page.searchtext" 
					:showAction='false'
					@clear="clear"
					@search="search">
				</u-search>
				<view class="wf-space-between">
					  <text class="descText">共{{ page.total }}条</text>
				  <view style="display: flex;align-items:center;justify-content: center;margin-right: 20rpx;">
					  <view class="wf-filter-isHistory" @click="isHistoryChange()">
						  <view style="border-radius: 10rpx 0 0 10rpx;" 
						  :class="page.isHistory==0?'filter-isHistory-item1':'filter-isHistory-item2'">未完结</view>
						  <view style="border-radius: 0 10rpx 10rpx 0;" 
						  :class="page.isHistory==1?'filter-isHistory-item1':'filter-isHistory-item2'">已完结</view>
					  </view>
					  <view class="ly-filter-item" @click="show = !show">
						  <text class="name">筛选</text>
						  <image style="width: 24upx; height: 24upx;margin: 0 2px;" src="../../static/oa/icon-xia.png">
						  </image>
					  </view>
				  </view>
				</view>
			</view>
		</view>
		<!-- //筛选列表 -->
		<view v-if="!show">
			<screen-prop type="2" :pageData="page" @filterSubmit="filterSubmit"></screen-prop>
		</view>
		<!-- 我的代办 -->
		<view class="todo_list" v-if="this.filelist[0]">
			<view class="rowf" v-for="(item, index) in filelist" :key="index">
				<view class="rowf_l">
					<image src="../../static/oa/danju.png" style="width: 70rpx;height:70rpx;vertical-align: bottom;"></image>
					<p class='rowf_txt'><text>{{ item.creatorRealName }}</text><span
							style='color:#999999'>丨</span><text>{{ item.appName }}</text>
					</p>
					<checkbox-group v-show="checkbox_show">
						<label>
							<checkbox @click="checkbox(item.state,index)" :checked="item.state" />
						</label>
					</checkbox-group>
				</view>

				<view class="">
					<view class="Hawork-work">
						<view class="Hawork_god_work">
							<span class='sright-work'>单据编号</span>
							<span class='sright-work-text'>{{ item.businessKey }}</span>
						</view>
						<view class="Hawork_god_work">
							<span class='sright-work'>当前节点</span>
							<span class='sright-work-text'>{{ item.currentActivityName }}({{item.currentActors}})</span>
						</view>
						<view class="Hawork_god_work">
							<span class='sright-work'>发起时间</span>
							<span class='sright-work-text'>{{ item.createdTime }}</span>
						</view>
						<view class="Hawork_god_work">
							<span class='sright-work'>主题内容</span>
							<span class='sright-work-text'>{{ item.workflowTitle }}</span>
						</view>
					</view>
				</view>
				<u-line></u-line>
				<view class="unik">
					<p class='texttwo' style='margin-right:20rpx ;' @click="openWorkflowfromView(item)">详  情</p>
				</view>
			</view>
		</view>
		<view class="todo_list" v-if="filelist.length == 0">
			<image  mode="widthFix" src="../../static/oa/pic_zanwushuju@3x.png" class="nomore_img">
			<view class="nomore_text">亲，暂无数据哟</view>
		</view>
		<!-- 底部 -->
		<view style="margin-bottom: 20rpx;" v-if="filelist.length > 0">
			<u-loading-icon :show='loadshow' mode="circle" timing-function="linear" duration="800" textSize='14'
				text='正在加载中...'></u-loading-icon>
				<p v-if="!loadshow" style='width: 100%;text-align: center;color: #666666;'>没有更多了...</p>
		</view>
		<!-- <Pagination @changePage='changePage' :total='page.total' :pageSize='page.pageSize' /> -->
	</view>
</template>

<script>
	import screenProp from "./screenProp.vue"
	export default {
		components: { screenProp },
		data() {
			return {
				checkbox_show: false, //批量处理选择
				show: true,
				tablist: [],
				skeyword: '', //搜索
				page: {
					WorkflowTitle: '',
					AppName: '',
					AppId: '',
					InCategoryCode: '',
					Urgency: '',
					SheetId: '',
					CreatorRealName: '',
					WorkflowInstanceState: '',
					StartTime: '',
					EndTime: '',
					searchtext: '',
					searchfields: 'SheetId,WorkflowTitle',
					isHistory: 0,
					page: 1,
					rows: 10,
					sort: 'startedTime',
					order: 'desc'
				}, //分页工具
				rows: [],
				filelist: [],
				preparation: [{ //筛选列表
						txt: '预算导入'
					},
					{
						txt: '供应商注册流程'
					},
					{
						txt: '出差申请单'
					},
					{
						txt: '一般申购单'
					},
				],
				loadshow: false,
			}
		},
		created() {
			this.loadList(1)

		},
		methods: {
			openWorkflowfromView:function(row) {
				var appId = row.appId;
				var formAction = 3;
				var wiid = row.workflowInstanceId;
				var taskId = row.taskId;
				var title = row.workflowTitle;
				var url = __webpath + "/workflow/businessMP/workflowform?formAction="+formAction+"&wiid=" + wiid ;
				FUI.Window.ngto(url);
				
			},
			layz() {
				let that = this
				setTimeout(function() {
					if (that.page.pageCount == that.page.page) {
						that.loadshow = false
						return false
					} else {
						that.loadshow = true
						that.page.page += 1;
						that.loadList()
						console.log('加载')
					}
				}, 200)

			},
			//获取列表数据
			loadList(pageIndex) {
				let that = this
				if(pageIndex == 1){
					that.page.page = pageIndex;
					that.rows= [];
				}
				var parms = {
					...that.page
				};
				that.$myObject.toAjaxJson("/workflow/workflowBusiness/", "getMyWorkItemList", parms, function(data) {
					if(data.success === true){
						that.page.total = data.total;
						that.page.pageCount = data.pageCount;
						for (let i = 0; i < data.rows.length; i++) {
							that.rows.push(data.rows[i])
						}
						that.filelist = that.rows
					}else{
						that.$api.showTip(data.msg);
					}
				});
			},
			isHistoryChange(){
				this.page.isHistory= this.page.isHistory==0 ? 1 : 0;
				this.loadList(1);
			},
			// 批量操作
			checkbox(state, index) {
				console.log(state, index)
			},
			//搜索
			search(value) {
				this.page.searchtext = value;
				this.loadList(1)
			},
			//清除搜索
			clear(){
				this.page.searchtext = "";
				this.loadList(1)
			},
			filterSubmit(obj){
				this.show= true
				this.page= obj;
				this.loadList(1)
			}
		}
	}
</script>

<style lang="scss" scoped>
	view {
		font-family: pf
	}
</style>
